package cn.wolfcode.commno;

import lombok.Getter;
import lombok.Setter;


@Setter
@Getter
public class JsonResult {
    private int code;   //响应数据的状态码 200 代表成功
    private String msg; //错误的时候 错误信息
    private Object data;//正常响应的数据信息

    public JsonResult() {}

    public JsonResult(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public JsonResult(String msg) {
        this.msg = msg;
    }

    public static JsonResult success(){
        return new JsonResult(200,"成功",null);
    }

    public static JsonResult success(Object data){
        return new JsonResult(200,"成功",data);
    }
    public static JsonResult error(String msg){
        return new JsonResult(500,"失败",null);
    }


    public static JsonResult loginError(String msg){
        return new JsonResult(msg);
    }

    public static JsonResult loginSuccess(String msg){
        return new JsonResult(msg);
    }

    public static JsonResult logout(){
        return new JsonResult(200,"注销成功",null);
    }

    public static JsonResult logout(String msg){
        return new JsonResult(200,msg,null);
    }

}
